/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.trace;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "trace_obj_underlying")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TraceObjUnderlying.findAll", query = "SELECT t FROM TraceObjUnderlying t"),
    @NamedQuery(name = "TraceObjUnderlying.findBySid", query = "SELECT t FROM TraceObjUnderlying t WHERE t.sid = :sid"),
    @NamedQuery(name = "TraceObjUnderlying.findByTraceType", query = "SELECT t FROM TraceObjUnderlying t WHERE t.traceType = :traceType"),
    @NamedQuery(name = "TraceObjUnderlying.findById", query = "SELECT t FROM TraceObjUnderlying t WHERE t.id = :id"),
    @NamedQuery(name = "TraceObjUnderlying.findByUnderlyingCode", query = "SELECT t FROM TraceObjUnderlying t WHERE t.underlyingCode = :underlyingCode"),
    @NamedQuery(name = "TraceObjUnderlying.findByRegionID", query = "SELECT t FROM TraceObjUnderlying t WHERE t.regionID = :regionID"),
    @NamedQuery(name = "TraceObjUnderlying.findByMarketCode", query = "SELECT t FROM TraceObjUnderlying t WHERE t.marketCode = :marketCode"),
    @NamedQuery(name = "TraceObjUnderlying.findByClassCode", query = "SELECT t FROM TraceObjUnderlying t WHERE t.classCode = :classCode"),
    @NamedQuery(name = "TraceObjUnderlying.findByUnderlyingName", query = "SELECT t FROM TraceObjUnderlying t WHERE t.underlyingName = :underlyingName"),
    @NamedQuery(name = "TraceObjUnderlying.findByCurrency", query = "SELECT t FROM TraceObjUnderlying t WHERE t.currency = :currency"),
    @NamedQuery(name = "TraceObjUnderlying.findByTick", query = "SELECT t FROM TraceObjUnderlying t WHERE t.tick = :tick"),
    @NamedQuery(name = "TraceObjUnderlying.findByTradeUnit", query = "SELECT t FROM TraceObjUnderlying t WHERE t.tradeUnit = :tradeUnit"),
    @NamedQuery(name = "TraceObjUnderlying.findByContractSize", query = "SELECT t FROM TraceObjUnderlying t WHERE t.contractSize = :contractSize"),
    @NamedQuery(name = "TraceObjUnderlying.findByOwnUserID", query = "SELECT t FROM TraceObjUnderlying t WHERE t.ownUserID = :ownUserID"),
    @NamedQuery(name = "TraceObjUnderlying.findByAlterUserID", query = "SELECT t FROM TraceObjUnderlying t WHERE t.alterUserID = :alterUserID"),
    @NamedQuery(name = "TraceObjUnderlying.findByCreateTime", query = "SELECT t FROM TraceObjUnderlying t WHERE t.createTime = :createTime"),
    @NamedQuery(name = "TraceObjUnderlying.findByTimeStamp", query = "SELECT t FROM TraceObjUnderlying t WHERE t.timeStamp = :timeStamp")})
public class TraceObjUnderlying implements Serializable {
	public static byte[] EnCode(TraceObjUnderlying msg) throws IOException {
		Codec<TraceObjUnderlying> Lcode = ProtobufProxy.create(TraceObjUnderlying.class);
		return Lcode.encode(msg);
	}
	public static TraceObjUnderlying DeCode(byte[] data) throws IOException {
	Codec<TraceObjUnderlying> Lcode = ProtobufProxy.create(TraceObjUnderlying.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "sid")
    @Protobuf
	private Integer sid;
    @Basic(optional = false)
    @Column(name = "TraceType")
    @Protobuf
	private String traceType;
    @Basic(optional = false)
    @Column(name = "id")
    @Protobuf
	private int id;
    @Basic(optional = false)
    @Column(name = "UnderlyingCode")
    @Protobuf
	private String underlyingCode;
    @Basic(optional = false)
    @Column(name = "RegionID")
    @Protobuf
	private String regionID;
    @Basic(optional = false)
    @Column(name = "MarketCode")
    @Protobuf
	private String marketCode;
    @Basic(optional = false)
    @Column(name = "ClassCode")
    @Protobuf
	private String classCode;
    @Column(name = "UnderlyingName")
    private String underlyingName;
	@Protobuf
	private byte[] underlyingNameBit;
    @Column(name = "Currency")
    @Protobuf
	private String currency;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Tick")
    @Protobuf
	private Float tick;
    @Basic(optional = false)
    @Column(name = "TradeUnit")
    @Protobuf
	private int tradeUnit;
    @Column(name = "ContractSize")
    @Protobuf
	private Integer contractSize;
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public TraceObjUnderlying() {
    }

    public TraceObjUnderlying(Integer sid) {
        this.sid = sid;
    }

    public TraceObjUnderlying(Integer sid, String traceType, int id, String underlyingCode, String regionID, String marketCode, String classCode, int tradeUnit) {
        this.sid = sid;
        this.traceType = traceType;
        this.id = id;
        this.underlyingCode = underlyingCode;
        this.regionID = regionID;
        this.marketCode = marketCode;
        this.classCode = classCode;
        this.tradeUnit = tradeUnit;
    }

    public Integer getSid() {
        return sid;
    }

    public void setSid(Integer sid) {
        this.sid = sid;
    }

    public String getTraceType() {
        return traceType;
    }

    public void setTraceType(String traceType) {
        this.traceType = traceType;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUnderlyingCode() {
        return underlyingCode;
    }

    public void setUnderlyingCode(String underlyingCode) {
        this.underlyingCode = underlyingCode;
    }

    public String getRegionID() {
        return regionID;
    }

    public void setRegionID(String regionID) {
        this.regionID = regionID;
    }

    public String getMarketCode() {
        return marketCode;
    }

    public void setMarketCode(String marketCode) {
        this.marketCode = marketCode;
    }

    public String getClassCode() {
        return classCode;
    }

    public void setClassCode(String classCode) {
        this.classCode = classCode;
    }

    public String getUnderlyingName() {
        return underlyingName;
    }

    public void setUnderlyingName(String underlyingName) {
        this.underlyingName = underlyingName;
        this.setUnderlyingNameBit(CodeTool.StringToBit(underlyingName));
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public Float getTick() {
        return tick;
    }

    public void setTick(Float tick) {
        this.tick = tick;
    }

    public int getTradeUnit() {
        return tradeUnit;
    }

    public void setTradeUnit(int tradeUnit) {
        this.tradeUnit = tradeUnit;
    }

    public Integer getContractSize() {
        return contractSize;
    }

    public void setContractSize(Integer contractSize) {
        this.contractSize = contractSize;
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sid != null ? sid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TraceObjUnderlying)) {
            return false;
        }
        TraceObjUnderlying other = (TraceObjUnderlying) object;
        if ((this.sid == null && other.sid != null) || (this.sid != null && !this.sid.equals(other.sid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.trace.TraceObjUnderlying[ sid=" + sid + " ]";
    }

    public byte[] getUnderlyingNameBit() {
        return underlyingNameBit;
    }

    public void setUnderlyingNameBit(byte[] underlyingNameBit) {
        this.underlyingNameBit = underlyingNameBit;
		this.underlyingName = CodeTool.BitToString(underlyingNameBit);
    }
    
}
